package com.grad.why.studentsystem.controller;

import com.grad.why.studentsystem.domain.Studentarrivedinfo;
import com.grad.why.studentsystem.domain.current.CurrentCaremaInfo;
import com.grad.why.studentsystem.domain.current.CurrentStudentArrivedInfo;
import com.grad.why.studentsystem.service.StudentarrivedinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/studentManageSystem")
public class PersonArrivedInfoController {
    @Autowired
    private StudentarrivedinfoService studentarrivedinfoService;

    @RequestMapping("/getPersonArrivedInfos")
    @ResponseBody
    public Object getCameraInfos(
            @RequestParam(required = false, defaultValue = "0", value = "offset") int offset,
            @RequestParam(required = false, defaultValue = "10", value = "limit") int limit,
            @RequestParam(required = false, defaultValue = "", value = "search") String search,
            @RequestParam(required = false, value = "order") String order
    ) {
        try {
            List<CurrentStudentArrivedInfo> rows = studentarrivedinfoService.getStudentArrivedInfoList(offset, limit, search);
            long total = studentarrivedinfoService.getStudentArrivedInfoListLength(search);
            Map<String, Object> result = new HashMap<>(2);
            result.put("rows", rows);
            result.put("total", total);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
